<template>
	<view>
		<gui-upload-imageso @change="images_change" ref="uploadimgcom" @uploaded="images_uploaded"	:formData="images_formData"></gui-upload-imageso>
	</view>
</template>

<script>
import autoUpdater from '@/components/autoUpdater.min.js';
export default {
	data() {
		return {
			imgServer:'',
			needPploadedImgs:[],//记录上传文件
			subtxt:'发布',//发布按钮
		};
	},
	onLoad() {
		this.imgServer=uni.common.imgServer
	},
	onShow() {
		console.log(uni.common.is_login());
		this.get_data()
		this.update()
	},
	methods: {
		//以下是 gui-upload-imageso
		images_change : function (e) {
			this.needPploadedImgs = e;
		},
		images_submit : function () {
			if(this.subtxt != '发布'){return ;}
			if(this.needPploadedImgs.length < 1){
				uni.showToast({title:"请选择图片", icon:"none"}); 
				return ;
			}
			this.subtxt = '提交中，请稍候 ...';
			this.$refs.uploadimgcom.upload();
		},
		images_uploaded : function (uploadedImgs) {
			let arr=[]
			for(let v of uploadedImgs){
				if(!v.error){
					arr.push(v.result.data)
				}
			}
			console.log(arr);
		},
		//以以上是 gui-upload-imageso
		
		async submit(e) { //上传图片
			let w;
			w=	await uni.common.uploadCards(this.idCard1);
			if(w && w.code==1){
				this.idCard11=w.data
			}
		},
		async tijiao(e) { //是否等待,请使用上方的is_login方法
			if(await uni.common.is_login()){
				
			}else{
				uni.commom.msg('请登陆后提交')
			}
		},
		get_data() {
			uni.common.post(
				uni.common.apiServer + 'index',
				{
					type: 'get_index_show',
				},
				false,
				res => {
					if (res.code == 1) {
						
					} else {
						uni.showToast({
							icon: 'none',
							title: '获取失败'
						});
					}
				},
				e => {
					console.log(e);
				}
			);
		},
		update(){
			uni.common.post(
				uni.common.apiServer + 'index',
				{
					type: 'update_app',
				},
				false,
				res => {
					if (res.code == 1) {
						if (res.app_v > plus.runtime.versionCode) {
							
							autoUpdater.init({
								packageUrl: res.url,
								content: res.desc,
								contentAlign: 'left',
								cancel: '取消该版本',
								cancelColor: '#007fff'
							});
							autoUpdater.show();
							
						}
					}else{
							uni.showToast({
								icon:'none',
								title:'最新版本无需升级！'
							})
						}
				},
				e => {
					console.log(e);
				}
			);
		},
		app_kefu(){
			// #ifdef APP-PLUS
			plus.runtime.openURL('mqqwpa://im/chat?chat_type=wpa&uin=821642',function (res) {
				plus.nativeUI.alert("本机没有安装QQ，无法启动");
			});
			// #endif
		},
	}
};
</script>

<style>

</style>

